package com.qf.entity;

import lombok.Data;

@Data
public class Result {

    public static final Integer SUCCESS = 1000;
    public static final Integer NO_LOGIN = 2000;
    public static final Integer NO_AUTH = 3000;

    private Object data;

    //是否成功的标志，只有两种情况
    //成功访问到数据，未登录，没有权限,...
    //private boolean flag;
    private  Integer code;

    private String msg;

    /**
     *  成功返回的数据
     * @param data
     * @return
     */
    public static Result success(Object data){
        Result result = new Result();
        result.setCode(SUCCESS);
        result.setData(data);
        return  result;
    }

    /**
     * 没有登录返回的数据
     * @param msg
     * @return
     */
    public static Result noLogin(String msg){
        Result result = new Result();
        result.setCode(NO_LOGIN);
        result.setMsg(msg);

        return result;
    }

    /**
     * 没有权限返回的数据
     * @param msg
     * @return
     */
    public static Result noAuth(String msg){
        Result result = new Result();
        result.setCode(NO_AUTH);
        result.setMsg(msg);

        return result;
    }
}
